package com.chen.web;

import com.chen.domain.User;
import com.chen.service.FeginConsumerHelloService;
import com.chen.service.RefactorHelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @decription
 * @atuhor:陈红卫
 * @create : 2017-06-18-10:47
 */
@RestController
public class ConsumerController {

    @Autowired
    FeginConsumerHelloService helloService;

    @RequestMapping(value = "/feign-consumer",method = RequestMethod.GET)
    public String helloConsumer(){
        return helloService.hello();
    }


    @Autowired
    private RefactorHelloService refactorHelloService;



    /*
    * @function:申明试服务调用，普通方法
    *
    * */
    @RequestMapping(value = "/feign-consumer2",method = RequestMethod.GET)
    public String helloCOnsumer2(){
        StringBuilder sb = new StringBuilder();
        sb.append(helloService.hello()).append("\n");

        sb.append(helloService.hello("DIDI")).append("\n");

        sb.append(helloService.hello("DIDI",23)).append("\n");

        sb.append(helloService.hello(new User(Long.valueOf(1),"周",1,"江西省上饶市 广丰"))).append("\n");


        return sb.toString();
    }



    /*
    * @function：申明试服务调用。通过继承的方式
    * */
    @RequestMapping(value = "/feign-consumer3",method = RequestMethod.GET)
    public String helloConsumer3(){

        StringBuilder sb = new StringBuilder();


        sb.append(refactorHelloService.hello("MIMI")).append("\n");

        sb.append(refactorHelloService.hello("MIMI",23)).append("\n");

        sb.append(refactorHelloService.hello(new User(Long.valueOf(1),"周",1,"江西省上饶市 广丰"))).append("\n");


        return sb.toString();
    }
}
